<!-- <script type="module" src="index.js"></script> -->
<script>
	 const encoded = [
  {
    groupId: 783,

    areaId: "0",
    departmentId: "688",
    directionId: "0",
    mediaTypeId: "0",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "0",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 784,

    areaId: "0",
    departmentId: "688",
    directionId: "0",
    mediaTypeId: "0",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "0",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 785,

    areaId: "0",
    departmentId: "688",
    directionId: "0",
    mediaTypeId: "0",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "0",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 786,

    areaId: "0",
    departmentId: "688",
    directionId: "0",
    mediaTypeId: "0",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "0",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 787,

    areaId: "0",
    departmentId: "688",
    directionId: "0",
    mediaTypeId: "0",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "0",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 788,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15130",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 789,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15152",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 790,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15130",
    formatId: "0",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: null,
    ca: null,
    mpmId: null,
  },
  {
    groupId: 791,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15130",
    formatId: "110639",
    unitId: "82226",
    platformId: "145868",
    budgetId: null,
    adPlatformId: "1557",
    service: null,
    formatSize: "не применим",
    ca: null,
    mpmId: null,
  },
  {
    groupId: 792,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15130",
    formatId: "110639",
    unitId: "82226",
    platformId: "145868",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: "не применим",
    ca: null,
    mpmId: null,
  },
  {
    groupId: 793,

    areaId: "0",
    departmentId: "688",
    directionId: "18858",
    mediaTypeId: "111",
    mediaId: "676",
    resellingId: "18842",
    serviceTypeId: "124",
    formatTypeId: "15152",
    formatId: "82193",
    unitId: "82226",
    platformId: "0",
    budgetId: null,
    adPlatformId: "1026",
    service: null,
    formatSize: "Не применимо",
    ca: null,
    mpmId: null,
  },
];

 const translations = {
  0: "",
  111: "СММ",
  124: "Размещение",
  676: "Диджитал",
  688: "Маркетинг",
  1026: "Telegram",
  1557: "Посевы",
  15130: "СММ - 2",
  15152: "Баннеры",
  18842: "Нет",
  18858: "СММ - 3",
  82193: "Баннеры",
  82226: "Фикс",
  110639: "Статья",
};
function isEmpty(value) {
 if (typeof value === 'undefined' || value === null || (typeof value === 'string' && value.trim().length === 0)) {
 return true;
 } else if (typeof value === 'object') {
 return Object.keys(value).length === 0 && value.constructor === Object;
 } else if (Array.isArray(value)) {
 return value.length === 0;
 } else {
 return false;
 }
}
//функция 
const exceptions = ['groupId', 'service', 'formatSize', 'ca']
const suffix = 'Id';
let unique = []
console.log(encoded)
let result = []
let tempObj = {}
for(let groupItem of encoded)
{
	//console.log(Object.keys(groupItem))
	for(let key of Object.keys(groupItem))
	{
		if(!exceptions.includes(key) && key.endsWith(suffix))
		{
			tempObj[key] = isEmpty(translations[groupItem[key]]) ? groupItem[key] : translations[groupItem[key]]
		}
		else
		{
			tempObj[key] =groupItem[key]
		}
		//console.log(groupItem[key])
		if(!unique.includes(groupItem[key]) && !isEmpty(groupItem[key]) && key.endsWith(suffix))
		{
			unique.push(groupItem[key])
		}
	}
	result.push(tempObj)
	tempObj = {}
}
console.log(result)
console.log(unique)
</script>